<extend name="./Application/Admin/View/common/base.html" />
<block name="crumb">
    <span class="c-gray en">&gt;</span> 模型管理
    <span class="c-gray en">&gt;</span> 修改模型
</block>
<block name="content">
    <form class="form form-horizontal" id="add-model">
        <input type="hidden" value="{$model['id']}" name="model_id">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>模型名称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" name="m_name" class="input-text" placeholder="例如：手机" value="{$model['m_name']}">
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"></label>
            <button id="save" class="btn btn-secondary radius" type="submit">
                <i class="Hui-iconfont">&#xe632;</i> 确认提交
            </button>
        </div>

    </form>
</block>

<block name="js">
    <script type="text/javascript">
    $(function(){

        //提交商品模型
        $('#save').click(function () {
            $("#add-model").validate({
                rules: {
                    m_name: {required: true, minlength: 2}
                },
                messages: {
                    m_name: {required: "请输入模型名称", minlength: "模型名称不少于2位"}
                },
                submitHandler: function(form) {
                    $(form).ajaxSubmit({
                        type: 'post',
                        url: "{:U('Model/edit')}",
                        data: {
                            model_id: $("input[name='model_id']").val(),
                            m_name: $("input[name='m_name']").val()
                        },
                        beforeSend: function () {
                            layer.msg('商品模型修改中..', {icon: 16,time:0});
                        },
                        success: function(msg) {
                            if (msg) {
                                layer.msg('修改商品模型成功!', {icon: 6,time:1000});
                                setTimeout(function(){ window.location.href = "{:U('Model/index')}"; }, 1000);
                            } else {
                                layer.msg('修改商品模型失败!', {icon: 2,time:1000});
                            }
                        }
                    });
                }
            });
        });


    });



</script>
</block>